﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SQLite;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Schedule
{
    class DataTableManage
    {
        public DataTable CourseDataTable { set; get; }
        public DataTableManage(DataTable dt)
        {
            this.CourseDataTable = dt;
        }

        public void dataTableInit()
        {
            CourseDataTable.Columns.Add("节数/周数", typeof(string));   //添加列集，下面都是
            CourseDataTable.Columns.Add("周一", typeof(string));
            CourseDataTable.Columns.Add("周二", typeof(string));
            CourseDataTable.Columns.Add("周三", typeof(string));
            CourseDataTable.Columns.Add("周四", typeof(string));
            CourseDataTable.Columns.Add("周五", typeof(string));
            CourseDataTable.Columns.Add("周六", typeof(string));
            CourseDataTable.Columns.Add("周日", typeof(string));

            for (int i = 0; i < 13; i++)  //用循环添加13个行集
            {
                DataRow dr = CourseDataTable.NewRow();
                CourseDataTable.Rows.Add(dr);
            }

            for (int i = 1; i < 14; i++)
            {

                CourseDataTable.Rows[i - 1][0] = i.ToString();//填入节数
            }

        }

        public void dataTableFill()
        {
            for (int weekday = 1; weekday < 8; weekday++)
            {//清空课程表
                for (int lesson = 0; lesson < 13; lesson++)
                {
                    CourseDataTable.Rows[lesson][weekday] = "";
                }
            }
        
            foreach (Course c in Course.courses){
                Console.WriteLine(c);
                //填充课程
                for (int i = 0; i < c.LastLesson; i++)
                {
                    CourseDataTable.Rows[c.BeginLesson -1 + i][c.Weekday] = c.Name;
                }
            }


        }
        

    }
     
}
